import request from "@/netword/request";
const fun = {};


// 分页查询所有信息
fun.getList = async (role) => {
    const res = await request({
        url: "/a/core/role/list",
        method: "post",
        params: {
            roleCode: role.roleCode,
            roleName: role.roleName,
            isSystem: role.isSystem,
            roleType: role.roleType,
            pageNo: role.pageNo,
            pageSize: role.pageSize,
            status: role.status
        }
    })
    return res.data;
}

// 分页查询所有信息
fun.getListAll = async () => {
    const res = await request({
        url: "/a/core/role/listAll",
        method: "post",
        params: {
        }
    })
    return res.data;
}

//保存数据
fun.saveRole = async (role) => {
    const res = await request({
        url: "/a/core/role/save",
        method: "put",
        params: {
            roleCode: role.roleCode,
            roleName: role.roleName,
            isSystem: role.isSystem,
            roleType: role.roleType,
            sort: role.sort,
            remarks: role.remarks,
        }
    })
    return res.data;
}


//更新数据
fun.updateRole = async (role) => {
    const res = await request({
        url: "/a/core/role/update",
        method: "post",
        params: {
            id: role.id,
            roleCode: role.roleCode,
            roleName: role.roleName,
            isSystem: role.isSystem,
            roleType: role.roleType,
            sort: role.sort,
            remarks: role.remarks,
        }
    })
    return res.data;
}

//修改数据状态（正常，停用，删除）
fun.saveStatus = async (id,status) => {
    const res = await request({
        url: "/a/core/role/updateStatus",
        method: "post",
        params: {
            id: id,
            status:status
        }
    })
    return res.data;
}

//查询单条数据
fun.getRole = async (id) => {
    const res = await request({
        url: "/a/core/role/get",
        method: "get",
        params: {
            id: id
        }
    })
    return res.data;
}


export default fun;